import torch
import matplotlib.pyplot as plt
import torch.nn as nn
import torch.nn.functional as F

class LeakyReLU(nn.Module):

    def __init__(self, negative_slope: float = 1e-2):
        super(LeakyReLU, self).__init__()
        self.negative_slope = negative_slope

    def forward(self, input):
        return F.leaky_relu(input, self.negative_slope)


def Curve(x):
    lr01 = LeakyReLU(0.01)
    y0 = lr01(x)

    lr02 = LeakyReLU(0.05)
    y1 = lr02(x)

    lr03 = LeakyReLU(0.1)
    y2 = lr03(x)

    lr04 = LeakyReLU(0.5)
    y3 = lr04(x)

    plt.title('LeakyReLU')
    plt.plot(x, y0, color='green', label='β=0.01')
    plt.plot(x, y1, color='blue', label='β=0.05')
    plt.plot(x, y2, color='red', label='β=0.1')
    plt.plot(x, y3, color='purple', label='β=0.5')
    plt.legend()
    plt.grid(True, linestyle='--', alpha=0.8)

    plt.xlabel('x')
    plt.ylabel('y')
    plt.show()


if __name__ == '__main__':
    x = torch.linspace(-3, 3, 10000)
    Curve(x)
